package com.att.control;

import java.util.List;

public class SendEventHandler implements CommandHandler {
	private DeviceEventConfig config;
	
	public void setConfig(DeviceEventConfig config) {
		this.config = config;
	}

	@Override
	public void press(String keycode) {
		List<String> array =  null;
		if ("KEYCODE_HOME".equals(keycode)) {
			array = CommandManager.homeCommand(config.getHomeCMD());
		} else if ("KEYCODE_BACK".equals(keycode)) {
			array = CommandManager.homeCommand(config.getBackCMD());
		} else if ("KEYCODE_MENU".equals(keycode)) {
			array = CommandManager.homeCommand(config.getMenuCMD());
		} else if ("KEYCODE_SEARCH".equals(keycode)) {
			array = CommandManager.homeCommand(config.getSearchCMD());
		}
		if (array != null) {
			execute(array);
		}
	}

	@Override
	public void touch(String x, String y) {
		List<String> array =  CommandManager.touchCommand(
				config.getTouchCMD(), x, y, config.getxExpress(), config.getyExpress());
		execute(array);
	}

	@Override
	public void drag(String startx, String starty, String endx, String endy,
			String steps, String during) {
		List<String> array =  CommandManager.dragCommand(
				config.getDragStartCMD(), config.getDragProcedureCMD(), config.getDragEndCMD(), 
				startx, starty, endx, endy, Integer.valueOf(steps), 
				config.getxExpress(), config.getyExpress());
		execute(array);
	}

	@Override
	public void longpress(String x, String y) {
		List<String> array =  CommandManager.LongpressCommand(
				config.getLongpressStartCMD(), config.getLongpressEndCMD(),
				x, y, config.getxExpress(), config.getyExpress());
		CommandManager.executeLongpressCommand(array);
	}

	@Override
	public void type(String str) {
		
	}

	@Override
	public void execute(List<String> cmd) {
		CommandManager.executeCommand(cmd);
	}

	@Override
	public void execute(String cmd) {

	}

	@Override
	public void init() {
		
	}

	@Override
	public void quit() {
		
	}

	@Override
	public void physicsLongpress(String keycode) {
		// TODO Auto-generated method stub
		
	}

}
